import axios from '@/plugins/axios';
const BASE_API = import.meta.env.VITE_APP_BASE_APIURL as string;

import { OrderTypes, ResponseVo, PageResult } from '@/type';

export namespace OrderService {
  export const page = async (params:Partial<OrderTypes.OrderParams>): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/order/page',{params, baseURL: BASE_API});
    return res;
  };

  export const createOrder = async (params:any): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/order/create',params,{baseURL: BASE_API});
    return res;
  };

  export const unusedOrder = async (params:any): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/order/unused',{params,baseURL: BASE_API});
    return res;
  };

  export const detailOrder = async (params:any): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/order/detail',{params,baseURL: BASE_API});
    return res;
  };
  

  export const useOrderCount = async (params:any): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/order/useOrderCount',params,{baseURL: BASE_API});
    return res;
  };

  export const orderRecordList = async (params:any): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/orderRecord/list',{params,baseURL: BASE_API});
    return res;
  };
  
  export const getStoreOrder = async(params:{
    storeCode:number,
    startTime:string,
    endTime:string
  }): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/order/getStoreOrder',{params,baseURL: BASE_API});
    return res;
  };

  export const refundOrder = async(params:{
      outTradeNo:string;
      reason:string;
  }): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/order/refundOrder',params,{baseURL: BASE_API});
    return res;
  };

  export const storeTodyOrderRecordCount= async(params:{
    storeCode:number,
    startTime:string,
    endTime:string
  }): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/orderRecord/todayRecordCount',{params,baseURL: BASE_API});
    return res;
  };
}